﻿@page "/login"
@using Known.Internals
@layout EmptyLayout
@inherits LoginPage

<div class="login">
    <div class="login-head">
        <div class="login-logo">
            <a class="kui-logo" href="@Config.SiteUrl" target="_blank" style="position:initial;height:55px;"></a>
            <div class="kui-app-name">@Language[AppConfig.AppName]</div>
        </div>
        <ul class="kui-menu">
            @if (Config.App.IsLanguage)
            {
                <li style="text-align:center;"><NavLanguage /></li>
            }
            @if (Config.App.IsTheme)
            {
                <li style="margin-left:15px;"><NavTheme /></li>
            }
        </ul>
    </div>
    <div class="login-body">
        <div class="login-left">
            <ul>
                <li>@Language[Language.OpenSource]</li>
                <li>@Language[Language.LowCode]</li>
                <li>@Language[Language.ModernUI]</li>
            </ul>
            <img src="img/login.png" />
        </div>
        <div class="login-form">
            <div class="login-form-body">
                <Tabs Animated>
                    <TabPane Key="Account" Tab="@Language[Language.LoginWithAccount]">
                        <LoginForm Model="Model" OnLogin="OnUserLogin" IsCaptcha="IsCaptcha" />
                    </TabPane>
                    <TabPane Key="QRCode" Tab="@Language[Language.LoginWithQRCode]">
                        <div style="text-align:center;">
                            <div style="margin-bottom:10px;">@Language[Language.ScanCodeWithMobile]</div>
                            <KQRCode Option="QrCode" />
                        </div>
                    </TabPane>
                </Tabs>
            </div>
        </div>
    </div>
    <div class="login-copyright"><KFooter /></div>
</div>

@code {
    private bool IsCaptcha => Config.System?.IsLoginCaptcha == true;
    private object QrCode => new { Text = Config.HostUrl, Width = 200, Height = 200 };

    // [CascadingParameter] private HttpContext HttpContext { get; set; }

    // protected override async Task OnInitAsync()
    // {
    //     await base.OnInitAsync();
    //     await HttpContext.SignOutAsync();
    // }

    // protected override async Task OnLoginedAsync(UserInfo user)
    // {
    //     await base.OnLoginedAsync(user);
    //     var url = Context.IsMobileApp ? "/app" : (ReturnUrl ?? "/");
    //     HttpContext.Response.Redirect(url);
    // }
}